<%--
  Created by IntelliJ IDEA.
  User: zhangbo
  Date: 2021/11/8
  Time: 8:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <script src="https://cdn.bootcss.com/jquery/3.1.1/jquery.js"></script>
    <script type="text/javascript">
        function a1() {
            $.post({
                url: "${pageContext.request.contextPath}/a3",
                data: {
                    "name": $("#uname").val()
                },
                success: function (data) {
                    if (data.toString() == "ok") {
                        $("#userInfo").css("color", "green");
                    } else {
                        $("#userInfo").css("color", "red");
                    }
                    $("#userInfo").html(data);

                }
            })
        }

        function a2() {
            $.post({
                url: "${pageContext.request.contextPath}/a3",
                data: {
                    "name": $("#upwd").val()
                },
                success: function (data) {
                    if (data.toString() == "ok") {
                        $("#userPwd").css("color", "green");
                    } else {
                        $("#userPwd").css("color", "red");
                    }
                    $("#userPwd").html(data);
                }
            })
        }

    </script>
</head>
<body>

<p>
    用户名：<input type="text" id="uname" name="uname" onblur="a1()">
    <span id="userInfo"></span>
</p>
<p>
    密码：<input type="text" id="upwd" name="uname" onblur="a2()">
    <span id="userPwd"></span>
</p>

</body>
</html>
